

#include <iostream>
#include <pthread.h>
#include <string.h>
namespace ns_task
{
    class Task
    {
    private:
        int x_;
        int y_;
        char op_;

    public:
        Task() {}
        Task(int x, int y, char op)
            : x_(x), y_(y), op_(op)
        {
        }

        std::string Show()
        {
            //转化为字符串
            std::string message = std::to_string(x_);
            message += op_;
            message += std::to_string(y_);
            message += "=?";
            return message;
        }

        int Run()
        {
            int res = 0;
            switch (op_)
            {
            case '+':
                res = x_ + y_;
                break;
            case '-':
                res = x_ - y_;
                break;
            case '*':
                res = x_ * y_;
                break;
            case '/':
                res = x_ / y_;
                break;
            default:
                std::cout << "wrong..." << std::endl;
                break;
            }
            std::cout << "当前任务被：" << pthread_self() << "处理" << x_ << op_ << y_ << "=" << res << std::endl;
            return res;
        }

        int operator()()
        {
            return Run();
        }

        ~Task() {}
    };
}


